'''[ac]广度优先搜索'''
from queue import Queue

def method(p, nums: list):
    mp = [False] * (p + 1)  # 记录点是否走过
    q = Queue()  # <x, step>
    for i in range(len(nums)):
        nums[i] %= p
        q.put((nums[i], 1))  # 注：可能有重复节点
        mp[nums[i]] = True
    if 0 in nums: return 1  # 已经有整倍的
    
    while not q.empty():
        x, step = q.get()
        # print(x, step, q)
        if x % p == 0: return step
        for n in nums:
            y = (x + n) % p
            if not mp[y] and y >= 0:
                q.put((y, step + 1))
                mp[y] = True
    return 0
     
if __name__ == '__main__':
    n, p = [int(x) for x in input().split()]
    nums = [int(x) for x in input().split()]
    ans = method(p, nums)
    print(ans)
